package ua.com.globallogic.training.generics;

import java.util.Arrays;

public class GenericArray  {

    public static <T extends Comparable<T>> T findMinimalElement(T[] array) {
        T minElement = array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i].compareTo(minElement) < 0) {
                minElement = array[i];
            }
        }
        return minElement;
    }

    public static <T extends Comparable<T>> void sort(T[] array) {
        Arrays.sort(array);
    }

    public static <T> void printArray(T[] array) {
        for (T element : array) {
            System.out.print(element + "\t");
        }
    }

}
